package com.example.taobaounion3.base;

import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import butterknife.ButterKnife;
import butterknife.Unbinder;

public abstract class BaseActivity extends AppCompatActivity {
    private Unbinder mBind;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(getLayoutId());
        mBind= ButterKnife.bind(this);
        initView();
        initEvent();
        initPresenter();
    }


    protected abstract void initPresenter();

    /**
     * 需要的时候覆盖
     */
    protected void  initEvent() {
    }

    protected abstract void initView();

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (mBind!=null){
            mBind.unbind();
        }
        this.release();
    }
    //如果子类需要释放资源，复写此方法
    protected void release() {

    }

    @Override
    protected void onSaveInstanceState(@NonNull Bundle outState) {
        super.onSaveInstanceState(outState);
    }

    protected abstract int getLayoutId();

}
